import {
	RECORD_croUser,
	GET_croUser,
	OUT_LOGIN,
} from './mutation-types.js'

import {setStore, getStore, removeStore} from '@/config/mUtils'

import {localapi, proapi} from '@/config/env'

export default {
	// 记录用户信息
	[RECORD_croUser](state, info) {
		state.croUser = info;
		state.login = true;
		// setStore('user_id', info.user_id);
		setStore('croUser', info);
	},
	//获取用户信息存入vuex
	[GET_croUser](state, info) {
		// if (state.croUser && (state.croUser.username !== info.username)) {
		// 	return;
		// };
		// if (!state.login) {
		// 	return
		// }
		if (info) {
			// state.croUser = {...info};
			state.login = true;
		} else {
			state.croUser = null;
			state.login = false;
		}
	},
	//退出登录
	[OUT_LOGIN](state) {
		state.croUser = null;
		removeStore('croUser');
	},

}
